import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:freedom/const/app_content.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../bloc/assets_manager_cubit.dart';
import '../bloc/assets_manager_state.dart';
import 'animated_ellipsis_text.dart';
import 'loading_indicator.dart';

class AssetsLoadingPage extends StatelessWidget {
  const AssetsLoadingPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
        decoration: const BoxDecoration(
            gradient: LinearGradient(
          begin: Alignment(1, 0.015),
          stops: [0.0, 0.5, 0.5, 1],
          colors: [
            AppContent.darkBlue,
            AppContent.darkBlue,
            AppContent.crtBackground,
            AppContent.crtBackground,
          ],
          tileMode: TileMode.repeated,
        )),
        child: Material(
          color: Colors.transparent,
          child: Center(
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: [
                const Padding(
                  padding: EdgeInsets.symmetric(horizontal: 20),
                ),
                const SizedBox(height: 40),
                AnimatedEllipsisText(
                  "加载中",
                  style: TextStyle(
                      fontSize: 30.h, color: Colors.white, height: 1.0),
                ),
                const SizedBox(height: 40),
                FractionallySizedBox(
                  widthFactor: 0.8,
                  child: BlocBuilder<AssetsManagerCubit, AssetsManagerState>(
                    builder: (context, state) {
                      return PinballLoadingIndicator(value: state.progress);
                    }, // PinballLoadingIndicator(value: 0.5),
                  ),
                ),
              ],
            ),
          ),
        ));
  }
}
